<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<title>${appname}-<c:if test="${!empty sessionScope._local_node_session}">${sessionScope._local_node_session.nodeName}-</c:if>${si:ctname("NET_TYPE",sessionScope._netType)}</title>
<%@ include file="/WEB-INF/view/common/css_js_ace.jsp"%>
<script type="text/javascript">
	function submit() {
		$("#searchForm").submit();
	}

	function monitorQuotaUpdate(id) {
		$.ajax({
			type : "GET",
			dataType : "html",
			cache : false,
			url : _ctx + "/registry/monitor_quota_update.do",
			data : {
				id : id
			},
			success : function(content) {
				$('#data').html(content);
				$('#myModal').modal('show');
			},
			error : function() {
				ui.msg('信息加载错误', 0);
			}
		});

	}
	function update() {
		var aps = $("input[name='alterPipeline']:checked");
		var apsVal = "";
		for ( var i = 0; i < aps.length; i++) {
			apsVal += $(aps[i]).val() + ",";
		}
		apsVal = apsVal.substring(0, apsVal.length - 1);
		if($("#ruleSn").val()== "" || $("#ruleSn").val() == null){
			alert("请选择告警条件!");
			return;
		}
		if ($("#value1").val() == "" || ($("#ruleSn").val()==4 &&($("#value1").val() == "" || $("#value2").val() == ""))) {
			alert("阈值为必填项,不能为空!");
		} else {
			$.ajax({
				type : "POST",
				dataType : "json",
				cache : false,
				url : _ctx + "/registry/update_monitor_quota.do",
				data : {
					id : $("#id").val(),
					quotaId : $("#quotaId").val(),
					alterTemplate : $("#alterTemplate").val(),
					ruleSn : $("#ruleSn").val(),
					value1 : $("#value1").val(),
					value2 : $("#value2").val(),
					alterPipeline : apsVal,
					remark : $("#remark").val()
				},
				success : function(content) {
					if (content.status == '1') {
						ui.msg(content.msg, 1);
						ui.go(_ctx + '/registry/monitor_quota_list.do');
					} else {
						ui.msg(content.msg, 0);
					}
					$('#myModal').modal('hide');
				},
				error : function() {
					ui.msg('信息加载错误', 0);
				}
			});
		}
	}

	function updateStatus(id, status) {
		$.ajax({
			type : "POST",
			dataType : "json",
			cache : false,
			url : _ctx + "/registry/update_status_monitor_quota.do",
			data : {
				id : id,
				status : status
			},
			success : function(content) {
				if (content.status == '1') {
					ui.msg(content.msg, 1);
					ui.go(_ctx + '/registry/monitor_quota_list.do');
				} else {
					ui.msg(content.msg, 0);
				}
				$('#myModal').modal('hide');
			},
			error : function() {
				ui.msg('信息加载错误', 0);
			}
		});
	}
	function changerule(){
		if($("#ruleSn").val()== '4'){
			$("label[name='val2']").css("display","");
		}else{
			$("label[name='val2']").css("display","none");
		}
		$("#value1").val("");
		$("#value2").val("");
	}
</script>
</head>
<body>
	<%@ include file="/WEB-INF/view/common/topbar.jsp"%>
	<div class="main-container" id="main-container">
		<div class="main-container-inner">
			<%@ include file="/WEB-INF/view/common/sidebar.jsp"%>
			<div class="main-content">
				<div class="breadcrumbs" id="breadcrumbs">
					<ul class="breadcrumb">
						<li><i class="icon-home home-icon"></i> <a href="#">首页</a></li>
						<li><a href="#">平台基础配置</a></li>
						<li><a href="#">告警配置</a></li>
						<li class="active">列表</li>
					</ul>
				</div>
				<div class="page-content">
					<div class="row">
						<div class="col-xs-12">
							<div class="hr hr12 hr-dotted"></div>
							<div class="table-responsive">
								<table class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<th class="center">序号</th>
											<th>指标项</th>
											<th>告警条件</th>
											<th>状态</th>
											<th>启用</th>
											<th>告警配置</th>
										</tr>
									</thead>
									<tbody>
										<c:forEach var="vo" items="${_data}" varStatus="idx">
											<tr>
												<td class="center">${idx.index + 1}</td>
												<td>${vo.name}</td>
												<td>
													<c:choose>
														<c:when test="${!empty vo.valueSug1 && !empty vo.valueSug2 && vo.ruleSug eq '4'}">
															${vo.valueSug1}&nbsp;~&nbsp;${vo.valueSug2}
														</c:when>
														<c:otherwise>
															${vo.ruleName}&nbsp;${vo.valueSug1}
														</c:otherwise>
													</c:choose>
												</td>
												<td>${si:ctname("OPENCLOSE",vo.status)}</td>
												<td>
													<div
														class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
														<c:if test="${vo.status eq 0 }">
															<a class="green" href="javascript:void(0);"
																onclick="updateStatus('${vo.id}','1');" title="开启">
																<i class="icon-play bigger-130"></i> </a>
														</c:if>
														<c:if test="${vo.status eq 1 }">
															<a class="red" href="javascript:void(0);"
																onclick="updateStatus('${vo.id}','0');" title="暂停">
																<i class="icon-pause bigger-130"></i> </a>
														</c:if>
													</div>
												</td>
												<td>
													<div
														class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
														<a class="blue" href="javascript:void(0);"
															onclick="monitorQuotaUpdate('${vo.id}');" title="配置">
															<i class="icon-pencil bigger-130"></i> </a>
													</div>
													<div id="myModal" class="modal fade" role="dialog"
														tabindex="-1" aria-labelledby="查看" aria-hidden="false">
														<div class="modal-dialog">
															<div class="modal-content">
																<div class="modal-header"></div>
																<div id="data"></div>
															</div>
														</div>
													</div>
												</td>
											</tr>
										</c:forEach>
									</tbody>
								</table>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>
